Last Update: 2025/3/26
Kling Image to Video API
The Image to Video API enables you to create video content from image using Kling's AI models. This document provides details about the API endpoint, parameters, and response structure.
Endpoint
POST https://platform.llmprovider.ai/v1/videos/image2video
Request Headers
Header | Value |
---|---|
Authorization | Bearer YOUR_API_KEY |
Content-Type | application/json |
Request Body
The request body should be a JSON object with the following parameters:
Field | Type | Description |
---|---|---|
model | string | The model to use. Options: kling-video-v1 , kling-video-v1-6 Default: kling-video-v1 |
image | string | Reference image. Accepts Base64 encoded image or URL. Image must be JPG/JPEG/PNG, max 10MB, min 300x300px, aspect ratio between 1:2.5-2.5:1 |
image_tail | string | (Optional) Reference image for tail frame control. Same format requirements as image parameter |
prompt | string | (Optional) Text prompt for video generation (max 2500 characters) |
negative_prompt | string | (Optional) Negative text prompt (max 2500 characters). Default: empty |
cfg_scale | float | (Optional) Generation freedom scale [0, 1]. Higher values mean stricter adherence to prompt. Default: 0.5 |
mode | string | (Optional) Generation mode. Options: std (standard), pro (professional quality). Default: std |
static_mask | string | (Optional) Static brush mask image. Same format requirements as image parameter |
dynamic_masks | array | (Optional) Dynamic brush configuration list (max 6 groups). Each group contains mask and trajectories |
duration | string | (Optional) Video duration in seconds. Options: 5 , 10 . Default: 5 |
external_task_id | string | (Optional) Custom task identifier (must be unique per user) |
Dynamic Masks Object Structure
Field | Type | Description |
---|---|---|
mask | string | Dynamic brush mask image |
trajectories | array | Movement trajectory coordinates (2-77 points) with x,y values |
{
"model": "kling-video-v1",
"mode": "pro",
"duration": "5",
"image": "https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg",
"prompt": "宇航员站起身走了",
"cfg_scale": 0.5,
"static_mask": "https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888177/cOLNrShrSO/static_mask.png",
"dynamic_masks": [
{
"mask": "https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888130/WU8spl23dA/dynamic_mask_1.png",
"trajectories": [
{
"x": 279,
"y": 219
},
{
"x": 417,
"y": 65
}
]
}
]
}
Response Body
The API returns a JSON object with the following structure:
Field | Type | Description |
---|---|---|
task_id | string | Generated task identifier |
task_info | object | Task creation parameters |
task_status | string | Task status: submitted , processing , succeed , failed |
created_at | integer | Task creation timestamp (milliseconds) |
updated_at | integer | Last update timestamp (milliseconds) |
Example Response
{
"task_id": "task_xyz789",
"task_info": {
"external_task_id": "custom_id_123"
},
"task_status": "submitted",
"created_at": 1722769557708,
"updated_at": 1722769557708
}
Example Request
- Shell
- nodejs
- python
curl -X POST https://platform.llmprovider.ai/v1/videos/image2video \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-video-v1",
"mode": "pro",
"duration": "5",
"image": "https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg",
"prompt": "宇航员站起身走了",
"cfg_scale": 0.5,
"static_mask": "https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888177/cOLNrShrSO/static_mask.png",
"dynamic_masks": [
{
"mask": "https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888130/WU8spl23dA/dynamic_mask_1.png",
"trajectories": [
{
"x": 279,
"y": 219
},
{
"x": 417,
"y": 65
}
]
}
]
}'
const axios = require('axios');
const apiKey = 'YOUR_API_KEY';
const url = 'https://platform.llmprovider.ai/v1/videos/image2video';
const data = {
model: 'kling-video-v1',
mode: 'pro',
duration: '5',
image: 'https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg',
prompt: '宇航员站起身走了',
cfg_scale: 0.5,
static_mask: 'https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888177/cOLNrShrSO/static_mask.png',
dynamic_masks: [
{
mask: 'https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888130/WU8spl23dA/dynamic_mask_1.png',
trajectories: [
{
'x': 279,
'y': 219
},
{
'x': 417,
'y': 65
}
]
}
]
};
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
};
axios.post(url, data, { headers })
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
import requests
import json
api_key = 'YOUR_API_KEY'
url = 'https://platform.llmprovider.ai/v1/videos/image2video'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
'model': 'kling-video-v1',
'mode': 'pro',
'duration': '5',
'image': 'https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg',
'prompt': '宇航员站起身走了',
'cfg_scale': 0.5,
'static_mask': 'https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888177/cOLNrShrSO/static_mask.png',
'dynamic_masks': [
{
'mask': 'https://h2.inkwai.com/bs2/upload-ylab-stunt/ai_portal/1732888130/WU8spl23dA/dynamic_mask_1.png',
'trajectories': [
{
'x': 279,
'y': 219
},
{
'x': 417,
'y': 65
}
]
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print('Response:', response.json())
else:
print('Error:', response.status_code, response.text)
For any questions or further assistance, please contact us at [email protected].